import java.util.LinkedList;

public class TestaForeach {

	public static void main(String[] args) {

		LinkedList<Integer> linkedList = new LinkedList<Integer>();

		int size = 100000;

		for (int i = 0; i < size; i++) {
			linkedList.add(i);
		}

		long tempo = TestaForeach.forTadicional(linkedList);
		System.out.println("For Tradicional: " + tempo + "ms");

		tempo = TestaForeach.foreach(linkedList);
		System.out.println("Foreach: " + tempo + "ms");
	}

	private static long forTadicional(LinkedList<Integer> lista) {
		long inicio = System.currentTimeMillis();

		for (int i = 0; i < lista.size(); i++) {

			int x = lista.get(i);
		}
		long fim = System.currentTimeMillis();

		return fim - inicio;
	}

	private static long foreach(LinkedList<Integer> linkedList) {
		long inicio = System.currentTimeMillis();
		for (Integer integer : linkedList) {

		}
		Long fim = System.currentTimeMillis();
		return fim - inicio;
	}

}
